package org.timeismoney.payment.service.impl;

import java.util.List;

import org.timeismoney.payment.dao.PaymentFinDao;
import org.timeismoney.payment.model.PaymentFin;
import org.timeismoney.payment.service.PaymentFinService;

public class PaymentFinServiceImpl extends BaseServiceImpl<PaymentFin, Integer>
		implements PaymentFinService {

	public List<PaymentFin> getFinsByStuNo(String stuNo) {
		return getDao()
				.find("from PaymentFin f left join fetch f.schoolYear left join fetch f.student where f.student.stuNo=? order by f.schoolYear.schoolYearNo desc",
						stuNo);
	}

	public PaymentFin getFinsByStuNoAndYearNo(String stuNo, Integer yearNo) {
		List<PaymentFin> list = getDao()
				.find("from PaymentFin f left join fetch f.schoolYear where f.student.stuNo=? and f.schoolYear.schoolYearNo=?",
						stuNo, yearNo);
		if (list != null && list.size() > 0) {
			return list.get(0);
		}
		return null;
	}

	public void deleteByStuNo(String stuNo) {
		((PaymentFinDao)getDao()).deleteByStuNo(stuNo);
	}

	public void deleteBySchoolYearNo(int schoolYearNo) {
		((PaymentFinDao)getDao()).deleteBySchoolYearNo(schoolYearNo);
	}

}
